#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
struct node
{
    long long d,v,a;
    bool flag = true;
}car[MAXN];
long long T;
long long n,m,l,V;
long long ans = 0;
long long p[MAXN];
long long vt;
bool vis[MAXN];
long long ans1 = 0;
void init()
{
    ans = 0;
    ans1 = 0;
    memset(vis,0,sizeof(0));
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--)
    {
        init();
        scanf("%lld",&n);
        scanf("%lld",&m);
        scanf("%lld",&l);
        scanf("%lld",&V);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&car[i].d);
            scanf("%lld",&car[i].v);
            scanf("%lld",&car[i].a);
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&p[i]);
        }
        for(int i=1;i<=n;i++)
        {
            if(car[i].flag)
            {
                for(int j=1;j<=m;j++)
                {
                    if(car[i].d <= p[j])
                    {
                        if(2*car[i].a*(p[j]-car[i].d)+car[i].v*car[i].v<0)
                        {
                            vt = 0;
                        }
                        else
                        {
                            vt = sqrt(abs(2*car[i].a*(p[j]-car[i].d)+car[i].v*car[i].v));
                        }
                        if(vt > V)
                        {
                            ans++;
                            vis[j] = true;
                            break;
                        }
                    }
                }
            }
        }
        for(int i=1;i<=m;i++)
        {
            if(!vis[i])
            {
                //cout << i << endl;
                ans1++;
            }
        }
        printf("%lld %lld\n",ans,ans1);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
